#include "Reading.h"

void save_random_raw_temp(string fname, size_t count);
int main()
{
	cout << "begin writing..." << endl;
	try
	{
		save_random_raw_temp("raw_temps_txt", 100000);
	}
	catch(exception& e)
	{
		cerr << e.what() << endl;
		system("pause");
		return 1;
	}
	catch(...)
	{
		cerr << "unknown error" << endl;
		system("pause");
		return 2;
	}

	cout << "...done" << endl;
	system("pause");
	return 0;
}

void save_random_raw_temp(string fname, size_t count)
{
	ofstream outs(fname);
	if (!outs)
		error("cannot write to file ", fname);
	
	size_t decicount = count/10;
	
	for (int i = 0; i < count; ++i)
	{
		int t   = randint(0, 20000);
		int h   = randint(0, 23);
		int sfn = randint(-30000, 30000);
		char sf;
		
		if (sfn%2==0)
			sf = 'C';
		else
			sf = 'F';
		
		double temp = double(t)/100;	
		outs << sf << '(' << h << ", " << temp << ')' << ' ';
		if (decicount > 0 && i%decicount==0)
			cout << '*';
	}
	
}